/**
 ******************************************************************************
 * @file    bsp_motor_driver.h
 * @author  ��Ӿ��
 * @date    2025/6/16
 * @version v1.1
 * @brief   �����������ͷ�ļ���֧�ֶ�ʵ��������ϡ��߸���
 ******************************************************************************
 */
#ifndef __BSP_MOTOR_DRIVER_H
#define __BSP_MOTOR_DRIVER_H

#include "mydefine.h"
#include "stdint.h"

typedef enum
{
    MOTOR_FORWARD = 0,
    MOTOR_REVERSE,
} MOTOR_DIR;

/**
 * @brief �����������ӳ��ṹ��
 */
typedef struct {
    GPIO_TypeDef* port[4];
    uint16_t      pin[4];
} MotorPinMap_t;

/**
 * @brief �������ʵ���ṹ��
 */
typedef struct {
    MotorPinMap_t pinmap;    // ����ӳ��
    uint8_t       phase;     // ��ǰ��λ
    uint32_t      last_tick; // �ϴβ���ʱ��
    uint16_t      step_count;// ���߲���
    uint16_t      target_step;// Ŀ�경��
} MotorHandle_t;

void Motor_Init(MotorHandle_t* motor, MotorPinMap_t pinmap);
void Motor_Step(MotorHandle_t* motor, MOTOR_DIR dir, uint32_t cycle);
void Motor_RunToAngle(MotorHandle_t* motor, MOTOR_DIR dir, uint32_t cycle, uint16_t angle);

#endif // __BSP_MOTOR_DRIVER_H
